package stream;

import stream.bean.Dish;
import stream.util.StreamDemoUtil;

import java.util.Arrays;
import java.util.List;

import org.junit.Test;

import static java.util.stream.Collectors.toList;

public class MapStreamDemo {

	@Test
	public void mapDemo() {
		List<Dish> menu = StreamDemoUtil.genDishList();
		List<String> dishNames = menu.stream()
				.map(Dish::getName)
				.collect(toList());
		System.out.println(dishNames);
	}
	
	@Test
	public void mapDemo1() {
		List<String> words = Arrays.asList("Java 8", "Lambdas", "In", "Action"); 
		List<Integer> wordLengths = words.stream()
				.map(String::length).collect(toList());
		System.out.println(wordLengths);
	}
	
	@Test
	public void mapDemo2() {
		List<String> words = Arrays.asList("Java 8", "Lambdas", "In", "Action"); 
		List<String> charlist = words.stream()
				.map(word -> word.split(""))
				.flatMap(Arrays::stream)
				.distinct()
				.collect(toList());
		System.out.println(charlist);
	}
	
	@Test
	public void test() {
		for(int i=1;i<101;i++) {
			
			String url = String.format("https://wetgif.com/wp-content/uploads/gif-rough-sex-%s.gif",i);
			System.out.println(url);
		}
	}
}
